import { useDeviceContext } from "@/providers/DeviceProvider";
import { Spin } from "antd";
import type { PropsWithChildren } from "react";

export default function WaitingDeviceLoaded({ children }: PropsWithChildren) {
  const { loading, device } = useDeviceContext();

  if (loading) {
    return (
      <Spin>
        <div className="h-20"></div>
      </Spin>
    );
  }

  if (!device) {
    return (
      <div className="pt-20 text-center text-sm">
        ❌&nbsp;错误：未获取到设备信息！
      </div>
    );
  }

  return children;
}
